<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %> 
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<!DOCTYPE html>
<html lang="zh-CN" >
<head>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>资产使用情况管理</title>
<style type="text/css">
    .searchArea .fieldBox .label{width: 80px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;}
</style>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
<div class="searchArea">
    <form id="searchBar">
        <div class="fieldset1 clearFix">
         <div class="fieldBox">
                <div class="label">项目名称</div>
                <div class="field">
                   <input name="fncprjnm" id="fncprjnm" type="text" class="ui-textbox" value="${fncprjnm}" ligerui="width: 200">
                </div>
            </div>
          <div class="fieldBox" >
                <div class="label">再融资状态</div>
                <div class="field">
               		 <select name="financingTypeCd" id="financingTypeCd" data-value=" " ligerui="width: 200">
                    	<option value=" " selected="selected">请选择</option>
                     		<option value="1">未占用</option>
                     		<option value="2">预占用</option>
                     		<option value="3">已占用</option>
                    </select>
                </div>
            </div> 
			<div class="fieldBox">
                <div class="label">融资资产种类</div>
                <div class="field">
                    <select name="astCd" id="astCd"  ligerui="width: 200" data-value=" ">
                    	<option value=" " selected="selected">请选择</option>
                         <c:forEach items="${astIdlist }" var="ct">
                     		<option value="${ct.key }">${ct.value }</option>
                        </c:forEach>
                    </select>
                </div>
            </div> 
            <div class="fieldBox">
                <div class="label">支付表号</div>
                <div class="field">
                   <input name="paySchNo" id="paySchNo" type="text" class="ui-textbox" value="" ligerui="width: 200">
                </div>
            </div>       
			<div class="fieldBox">
                <div class="label">是否预约</div>
                <div class="field">
                	<select name="isYl" id="isYl" data-value=" " ligerui="width: 200">
                    	<option value=" " selected="selected">请选择</option>
                        <option value="1" >是</option>
                        <option value="0" >否</option>
                    </select>
                </div>
            </div>        
			<div class="fieldBox">
                <div class="label">到期时间</div>
                <div class="field">
                    <input name="expireDateStart" id="expireDateStart" type="text" class="ui-datepicker" value="" ligerui="width: 200">
                    <input name="expireDateEnd" id="expireDateEnd" type="text" class="ui-datepicker" value="" ligerui="width: 200">
                </div>
            </div> 
           <div class="fieldBox" >
                <div class="label">质押历史</div>
                <div class="field">
               		 <select name="isPledge" id="isPledge" data-value=" " ligerui="width: 200">
                    	<option value=" " selected="selected">请选择</option>
                     		<option value="1">有</option>
                     		<option value="0">无</option>
                    </select>
                </div>
            </div>    
            <div class="clearFix"></div>
            <div class="btnsBox formBtns notRight">
                <span id="searchBtn" class="sq-button-round">查询</span>
                <span id="clearBtn" class="sq-button-round">清空</span>
                <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
            </div>
            <div class="fieldBox col_100" style="display:none;">
            	 <c:forEach items="${expireList }" var="expire">
                     <input type="hidden" id="is_expire" value="${expire.key}" >
                 </c:forEach>
            </div>
          </div>
        </form>
    </div>
</div>
<div id="ligergrid1" class="sq-grid"></div>

<script type="text/javascript">
	var grid = null;
	$(function () {
		initAssUsageList();
	});
	
	function initAssUsageList(){
		$("#searchBar").ligerForm({validate: true});
		var _url = '<%=path%>/rfbuss/fncprjbscinfo/initAssUseList.do';
		grid = $("#ligergrid1").ligerGrid({
	   		url : _url,
	   		method : 'get',
	       	columns: [
	            { display: '融资资产种类', name: 'astNm', width: 120,
	            	render:function(rowdata, rowindex, value){
		            	  if(13==rowdata.fncprjstcd || 14==rowdata.fncprjstcd ){
		            		  return "";
		            	  }else{
		            		  return rowdata.astNm; 
		            	  }
		              }	
	            },
	            { display: '支付表号', name: 'paySchNo', width: 200},
	            { display: '项目名称', name: 'fncprjnm', width: 180,
	            	render:function(rowdata, rowindex, value){
		            	  if(13==rowdata.fncprjstcd || 14==rowdata.fncprjstcd ){
		            		  return "";
		            	  }else{
		            		  return rowdata.fncprjnm; 
		            	  }
		              }
	            },
	            { display: '再融资状态', name: 'financingTypeCd', width: 120,
	              render:function(rowdata, rowindex, value){
	            	  if(value=='1'){
	            		  return "未占用";
	            	  }else if (value=='2'){
	            		  return "预占用"; 
	            	  }else if (value=='3'){
	            		  return "已占用";
	            	  }
	              }	
	            },
	            { display: '是否预约', name: 'isYl', width: 100,
	            	render:function(rowdata, rowindex, value){
	            		if(value=='1'){
		            		  return "是";
		            	  }else if (value=='0'){
		            		  return "否"; 
		            	  }
	            	}	
	            },
	            { display: '预约资产包名称', name: 'assPackNm', 
	            	render:function(rowdata, rowindex, value){
	            		  var h="";
	            		  if(rowdata.isYl=='1'){
	            			  h+='<span title="'+ rowdata.assPackNm + '">'+rowdata.assPackNm+'</span>';
		            	  }
		            	  return h; 
	            	}	
	            },
	            { display: '放款时间', name: 'transtm', width: 100,render:renderDate},
	            { display: '到期时间', name: 'expireDate', width: 100,render:renderDate1},
	            { display: '操作', minWidth: 150 ,height:'100px', align:'center',
	            	render: function (rowdata, rowindex, value){
	            		var h="";
	            		    h+='<a class="sq-button-hasicon" href="javascript:paySchView(';
			                h+="'"+rowdata.paySchNo+"'";
			                h+=")\"><i class='sqBtnIco_4'></i>查看详情</a>";
			                //h+=' | ';
	                    if(rowdata.isPledge=='1'){
	                    	h+='<a class="sq-button-hasicon" href="javascript:mortgageList(';
			                h+="'"+rowdata.paySchNo+"'";
			                h+=")\"><i class='sqBtnIco_4'></i>质押记录</a>";
	                    }else {
	                    	
	 	                    h+="<font color='#CCCCCC'>质押记录</font>";
	                    }
	                	return h;
	            	}
	            },
	        ],
	        pageSize:10, 
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        height:'100%',
	        heightDiff:-2,
	        checkbox:false,
	        rownumbers:true
	
	   	});
	    grid = liger.get("ligergrid1");
	    grid.setHeight(100);
	    $("#searchBar").ligerForm();
	}
	
	$("#searchBtn").click(function(event) {
	    var form = new liger.get("searchBar");
	    if (!form.valid()) {
			top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO,SQ_type: "warning"});
			return false; //验证不通过，不执行以下代码
		}
	    $("#flag").val("1");
	    var data = form.getData();
	    for (var name in data){
	       grid.setParm(name,data[name]);
	    };
	   grid.reload();
	});
	
	$("#clearBtn").click(function(event) {
	    $("#resetBtn").click();  //重置 input-text
	    var form = liger.get("searchBar");
	    form.setData({  //重置select等特殊表单
	        "fncprjnm": " ",
	        "financingTypeCd": " ",
	        "paySchNo": " ",       
	        "astCd": " ",
	        "expireDateStart": " ",
	        "expireDateEnd": " ",
	        "isPledge": " ",
	        "isYl": " "
	    });
	});
	

	//格式化时间
	function renderDate(rowdata, index, value){
		var fncprjstcd=rowdata.fncprjstcd;
		if(13==fncprjstcd || 14==fncprjstcd ){//项目结束或者作废，取消关联
  		  return "";
  	   }
		var dateStr = "";
		if(null != value){
			var date = new Date(value);
			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
		}
		return dateStr;
	}
  function mortgageList(paySchNo){
		
		$.ligerDialog.SQopen({
            cls: 'noBorder_Dialog',
            width: 700,
            height:600,
            title : '抵押记录',
            url:'<%=path%>/ass/asspackinfo/toMortgageList.do?paySchNo=' + paySchNo
        });
	}
	
 function paySchView(paySchNo){
		
		$.ligerDialog.SQopen({
            cls: 'noBorder_Dialog',
            width: 400,
            height:500,
            title : '查看详情',
            url:'<%=path%>/ass/asspackinfo/paySchView.do?paySchNo=' + paySchNo
        });
	}
	//格式化时间
	function renderDate1(rowdata, index, value){
		var dateStr = "";//到期日期
		var imgpath ="<%=path%>/resource/lib/images/red.gif";//代表小灯泡
		var img='<img alt="" width="20px" height="20px" src="'+imgpath+'">';
		var is_expire=$('#is_expire').val();
		var date="";//到期日期
		var date3="";//到期时间减去30(is_expire)天之后
		var fncprjstcd=rowdata.fncprjstcd;
		if(13==fncprjstcd || 14==fncprjstcd ){
  		  return "";
  	   }
		if(null != value){
			date = new Date(value);
			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
			var financingTypeCd=rowdata.financingTypeCd;
			if(financingTypeCd=='1' || financingTypeCd=='2' ){
				return dateStr;
			}else if (financingTypeCd=='3'){
				//到期时间减去30天
				if(is_expire>0){
					date3 = date.valueOf()
					date3 = date3 - is_expire * 24 * 60 * 60 * 1000
					date3 = new Date(date3);
					//当前时间
					var curdate = new Date();
					if(curdate>=date3){////到期提前30日期大于等于当前日期，就提醒
						var zhong=dateStr;
						dateStr=img;
						dateStr+=zhong;
					}
				}
			}
		}
		return dateStr;
	}

	
</script>
</body>
</html>